package com.one.blocks.mvc.valid.constraints;

import com.one.blocks.mvc.valid.validator.UniqueManager;
import com.one.blocks.mvc.valid.validator.UniqueValidatorForInteger;
import com.one.blocks.mvc.valid.validator.UniqueValidatorForLong;
import com.one.blocks.mvc.valid.validator.UniqueValidatorForString;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author <a href="mailto:idler41@163.com">linfuxin</a> created by 2022-12-11 09:59:39
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = {
        UniqueValidatorForInteger.class,
        UniqueValidatorForLong.class,
        UniqueValidatorForString.class,
})
public @interface Unique {

    String message() default "存在重复数据";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    Class<? extends UniqueManager<?>> manager();
}
